﻿<UserControl
    x:Class="FU.Capstones.IMS.Web.Silverlight.Views.ExportProductOrder"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Commands="clr-namespace:Microsoft.Practices.Prism.Commands;assembly=Microsoft.Practices.Prism"
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
    xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
    xmlns:Controls="clr-namespace:FU.Capstones.IMS.Web.Silverlight.Controls" 
    xmlns:Navigation="clr-namespace:Navigation.Silverlight;assembly=Navigation.Silverlight" 
    xmlns:TControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input" 
    xmlns:Common="clr-namespace:FU.Capstones.IMS.Web.Common;assembly=FU.Capstones.IMS.Web.Common" xmlns:Groupbox="clr-namespace:Groupbox;assembly=Groupbox" Navigation:ViewModel.TypeName="FU.Capstones.IMS.Web.Silverlight.ViewModels.ExportProductOrderViewModel"
    >

    <UserControl.Resources>
        <Common:DataContextProxy x:Key="DataContextProxy"/>
    </UserControl.Resources>
    <telerik:RadBusyIndicator 
        BusyContent="Đang kết nối tới máy chủ..." 
        IsBusy="{Binding Path=ServiceCallCounter, Converter={StaticResource IntegerToBoolConverter}}">
        <Grid x:Name="LayoutRoot" Style="{StaticResource ViewGridStyle}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="10"/>
                <RowDefinition Height="85"/>
                <RowDefinition Height="158" />
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="10"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <!--Title-->
            <Grid Grid.ColumnSpan="3">

                <Grid.Background>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop0}"/>
                        <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop1}"/>
                        <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop2}"/>
                        <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop3}"/>
                    </LinearGradientBrush>
                </Grid.Background>

                <TextBlock 
                        x:Name="lblTitle"                                     
                        Text="Đơn hàng xuất - nhập sản phẩm"
                        Style="{StaticResource TextBlockTitlePageStyle}"/>
            </Grid>
            
            <!--GroupBox product order information-->
            <Groupbox:GroupBox Grid.Column="1" Grid.Row="2" Grid.RowSpan="2">
                <Groupbox:GroupBox.Header>
                    <TextBlock Text="Thông tin đơn hàng" Style="{StaticResource TextBlockGroupBoxTitleStyle}"/>
                </Groupbox:GroupBox.Header>
                <Grid Margin="5,2">
                    <!--Text box field-->
                    <Grid x:Name="TextBoxField">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="40"/>
                            <RowDefinition Height="40"/>
                            <RowDefinition Height="40"/>
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid Grid.Row="0" Grid.Column="0">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <TextBlock Text="Nhập ngày làm hóa đơn hoặc để trống" 
                               Grid.Row="0" Grid.Column="0"
                               Style="{StaticResource TextBlockNormalStyle}"
                               VerticalAlignment="Center"
                               HorizontalAlignment="Left">

                            </TextBlock>
                            <TControls:RadDatePicker
					            x:Name="txtCreateDate"
					            Grid.Row="2" Grid.Column="1" Width="230"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Center"
                                TextAlignment="Center"
                                SelectedValue="{Binding Path=EnterDateTime, Mode=TwoWay}">
                            </TControls:RadDatePicker>

                        </Grid>

                        <Grid Grid.Column="1" Grid.Row="0">
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="20"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <RadioButton GroupName="importExportButton" 
                                x:Name="RadImport"
                                Grid.Column="1" Grid.Row="0"
                                IsChecked="{Binding Path=IsImported, Mode=TwoWay}"
                                Command="{Binding Path=RadCheck, Mode=TwoWay}"
                                Content="Nhập kho" Margin="10" />
                            <RadioButton GroupName="importExportButton" 
                                x:Name="RadExport"
                                Grid.Column="2" Grid.Row="0"
                                IsChecked="{Binding Path=IsExported, Mode=TwoWay}"
                                Command="{Binding Path=RadCheck, Mode=TwoWay}"
                                Content="Xuất kho" Margin="10"/>
                            <RadioButton GroupName="internalExternalButton" 
                                x:Name="RadEnteranl"
                                Grid.Column="1" Grid.Row="1"
                                IsChecked="{Binding Path=IsInternal, Mode=TwoWay}"
                                Command="{Binding Path=RadInExCheck, Mode=TwoWay}"
                                Content="Nội bộ" Margin="10" />
                            <RadioButton GroupName="internalExternalButton" 
                                x:Name="RadExternal"
                                Grid.Column="2" Grid.Row="1"
                                IsChecked="{Binding Path=IsExternal, Mode=TwoWay}"
                                Command="{Binding Path=RadInExCheck, Mode=TwoWay}"
                                Content="Với đối tác" Margin="10"/>
                        </Grid>

                        <!--Person in charge-->
                        <TextBlock
                            Style="{StaticResource TextBlockNormalStyle}"
                            Grid.Column="0" Grid.Row="2">
                            <Run Text="Người làm hóa đơn " />
                            <Run Foreground="Red" Text="*" />
                        </TextBlock>
                        <ComboBox 
                            x:Name="cbPersonInCharge" 
                            Style="{StaticResource ComboBoxNormalStyle}"
                            Width="230"
                            Grid.Column="1" Grid.Row="2"
                            HorizontalAlignment="Right"
                            ItemsSource="{Binding Path=EmployeeACollection, Mode=TwoWay}"
                            DisplayMemberPath="FullName"
                            SelectedItem="{Binding Path=ProductOrder.EmployeeA, Mode=TwoWay}">
                        </ComboBox>

                        <!--Person order-->
                        <TextBlock
                            Style="{StaticResource TextBlockNormalStyle}"
                            Grid.Column="0" Grid.Row="1">
                            <Run Text="Người làm yêu cầu " />
                            <Run Foreground="Red" Text="*" />
                        </TextBlock>
                        <ComboBox 
                            x:Name="cbPersonOrderInternal" 
                            Style="{StaticResource ComboBoxNormalStyle}"
                            Width="230"
                            Grid.Column="1" Grid.Row="1" 
                            HorizontalAlignment="Right"
                            Visibility="{Binding Path=IsInternal, Mode=TwoWay,Converter={StaticResource BoolToVisibilityConverter}}"
                            ItemsSource="{Binding Path=EmployeeBCollection, Mode=TwoWay}"
                            DisplayMemberPath="FullName"
                            SelectedItem="{ Binding Path=ProductOrder.EmployeeB,Mode=TwoWay}">
                        </ComboBox>
                        <ComboBox 
                            x:Name="cbPersonOrderExternal" 
                            Style="{StaticResource ComboBoxNormalStyle}"
                            Width="230"
                            Grid.Column="1" Grid.Row="1"
                            HorizontalAlignment="Right"
                            Visibility="{Binding Path=IsExternal, Mode=TwoWay,Converter={StaticResource BoolToVisibilityConverter}}"
                            ItemsSource="{Binding Path=ContactCollection, Mode=TwoWay}"
                            DisplayMemberPath="FullName"
                            SelectedItem="{ Binding Path=ProductOrder.Contact,Mode=TwoWay}">
                        </ComboBox>
                        <!--Store-->
                        <TextBlock
                            Style="{StaticResource TextBlockNormalStyle}"
                            Grid.Column="0" Grid.Row="3">
                            <Run Text="Kho " />
                            <Run Foreground="Red" Text="*" />
                        </TextBlock>
                        <ComboBox 
                            x:Name="cbStore" 
                            Style="{StaticResource ComboBoxNormalStyle}"
                            Width="230"
                            Grid.Column="1" Grid.Row="3"
                            HorizontalAlignment="Right"
                            ItemsSource="{Binding Path=WarehouseCollection, Mode=TwoWay}"
                            DisplayMemberPath="WarehouseName"
                            SelectedItem="{Binding Path=SelectedWarehouse,Mode=TwoWay}">
                        </ComboBox>

                        <Grid Grid.Column="1" Grid.Row="3">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>

                        </Grid>                         
                    </Grid>

                </Grid>
            </Groupbox:GroupBox>

            
            <!--GroupBox List Product-->
            <Groupbox:GroupBox Grid.Column="1" Grid.Row="4">
                <Groupbox:GroupBox.Header>
                    <TextBlock Text="Danh sách sản phẩm" Style="{StaticResource TextBlockGroupBoxTitleStyle}"/>
                </Groupbox:GroupBox.Header>
                <Grid Margin="5,2">
                    <!--Grid view-->
                    <telerikGrid:RadGridView    
                        x:Name="grvOrderMaterial"
                        Width="Auto"
                        Grid.Row="3"
                        Grid.Column="1"
                        Style="{StaticResource RadGridViewNormal}"
                        ItemsSource="{Binding Path=PagedCollectionProduct}">
                        <telerikGrid:RadGridView.Columns>
                            
                            <telerikGrid:GridViewDataColumn 
                                DataMemberBinding="{Binding Path=ProductCode,Mode=OneWay}"                    
                                Header="Mã sản phẩm"
                                TextAlignment="Left"
                                Width="130" HeaderTextAlignment="Center">                                
                            </telerikGrid:GridViewDataColumn>
                            
                            <telerikGrid:GridViewDataColumn 
                                DataMemberBinding="{Binding Path=ProductName}"
                                Header="Tên sản phẩm"
                                TextAlignment="Left"
                                Width="140" HeaderTextAlignment="Center">                                
                            </telerikGrid:GridViewDataColumn>
                            
                            <telerikGrid:GridViewDataColumn                       
                                Header="Số lượng"
                                IsReadOnly="True"                       
                                Width="80" HeaderTextAlignment="Center" 
                                TextAlignment="Right"                                                 
                                DataMemberBinding="{Binding Path=Quantity}">
                            </telerikGrid:GridViewDataColumn>
                            
                            <telerikGrid:GridViewDataColumn                       
                                Header="Đơn giá"
                                Width="100" HeaderTextAlignment="Center"    
                                TextAlignment="Right"
                                DataMemberBinding="{Binding Path=PricePerUnit, Mode=TwoWay,Converter={StaticResource DecimalToVnCurrencyConverter}}">
                            </telerikGrid:GridViewDataColumn>
                            
                            <telerikGrid:GridViewColumn Width="Auto"  Header="Xóa">
                                <telerikGrid:GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <HyperlinkButton 
                                            Content="Xóa"    
                                            Commands:Click.Command="{Binding Path=DataSource.DeleteCommand, 
                                                                                Source={StaticResource DataContextProxy}}"
                                            Commands:Click.CommandParameter="{Binding Path=ProductID}"
                                        />
                                    </DataTemplate>
                                </telerikGrid:GridViewColumn.CellTemplate>
                            </telerikGrid:GridViewColumn>
                            
                        </telerikGrid:RadGridView.Columns>

                    </telerikGrid:RadGridView>

                </Grid>
                
            </Groupbox:GroupBox> 
            <StackPanel
                Orientation="Horizontal" HorizontalAlignment="Center"                
                Grid.Column="1" Grid.Row="6">
                <!--Buttons-->
                <Controls:AddNewButtonControl                         
                        Visibility ="{Binding Path=CanAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                        />
                <Controls:SaveButtonControl 
                    Visibility ="{Binding Path=CanEditOrAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                    />

                <Controls:ResetButtonControl 
                    Visibility ="{Binding Path=CanEditOrAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                    />

                <Controls:BackButtonControl
                    />
            </StackPanel>
        </Grid>
    </telerik:RadBusyIndicator>
</UserControl>
